package cn.com.acca.ma.dao.impl;

import cn.com.acca.ma.dao.QuantAccountLogDao;
import cn.com.acca.ma.model.QuantAccountLog;

public class QuantAccountLogDaoImpl extends BaseDaoImpl<QuantAccountLog> implements
        QuantAccountLogDao {

    /**
     * 根据date，更新所有MA列
     * @param date
     */
    @Override
    public void writeQuantAccountLogMAByDate(String date) {
        logger.info("根据date，更新所有MA列");

        String sql = "{call PKG_QUANT_ACCOUNT_LOG.CALCULATE_FIVE(?)}";

        // 参数
        Object[] inParameter = new Object[1];
        inParameter[0] = date;
        Class[] inParameterType = new Class[2];
        inParameterType[0] = String.class;

        // 根据date，更新所有MA列
        doProcedureInTransaction(sql, null, inParameter, inParameterType);
    }

    /**
     * 根据date，更新所有bias列
     * @param date
     */
    @Override
    public void writeQuantAccountLogBiasByDate(String date) {
        logger.info("根据date，更新所有bias列");

        String sql = "{call PKG_QUANT_ACCOUNT_LOG.WRITE_BIAS_BY_DATE(?)}";

        // 参数
        Object[] inParameter = new Object[1];
        inParameter[0] = date;
        Class[] inParameterType = new Class[1];
        inParameterType[0] = String.class;

        // 根据date，更新所有bias列
        doProcedureInTransaction(sql, null, inParameter, inParameterType);
    }

    /**
     * 更新所有MA列
     */
    @Override
    public void writeQuantAccountLogMA() {
        logger.info("更新所有MA列");

        String sqlMa5 = "{call PKG_QUANT_ACCOUNT_LOG.CALCULATE_FIVE}";
        String sqlMa10 = "{call PKG_QUANT_ACCOUNT_LOG.CALCULATE_TEN}";
        String sqlMa20 = "{call PKG_QUANT_ACCOUNT_LOG.CALCULATE_TWENTY}";
        String sqlMa60 = "{call PKG_QUANT_ACCOUNT_LOG.CALCULATE_SIXTY}";
        String sqlMa120 = "{call PKG_QUANT_ACCOUNT_LOG.CALCULATE_ONEHUNDREDTWENTY}";
        String sqlMa250 = "{call PKG_QUANT_ACCOUNT_LOG.CALCULATE_TWOHUNDREDFIFTY}";

        // 参数
//        Object[] inParameter = new Object[1];
//        inParameter[0] = modelId;
//        Class[] inParameterType = new Class[1];
//        inParameterType[0] = Integer.class;

        // 根据modelId，更新所有MA列
        doProcedureInTransaction(sqlMa5, null, null, null);
        doProcedureInTransaction(sqlMa10, null, null, null);
        doProcedureInTransaction(sqlMa20, null, null, null);
        doProcedureInTransaction(sqlMa60, null, null, null);
        doProcedureInTransaction(sqlMa120, null, null, null);
        doProcedureInTransaction(sqlMa250, null, null, null);
    }

    /**
     * 更新所有bias列
     */
    @Override
    public void writeQuantAccountLogBias() {
        logger.info("更新所有bias列");

        String sql = "{call PKG_QUANT_ACCOUNT_LOG.WRITE_BIAS}";

        // 参数
//        Object[] inParameter = new Object[1];
//        inParameter[0] = modelId;
//        Class[] inParameterType = new Class[1];
//        inParameterType[0] = Integer.class;

        // 更新所有bias列
        doProcedureInTransaction(sql, null, null, null);
    }

    public QuantAccountLogDaoImpl() {
        super();
    }
}
